<?php
/**
 * Created by PhpStorm.
 * User: chentaohua
 * Date: 2019/1/5
 * Time: 16:08
 */

namespace app\admin\model;

use think\Model;

class Member extends Model{

    /**
     * 会员充值
     * @param array $user 充值用户信息
     * @param
     */
    public function recharge($userId,$amount){
        $member = $this -> where('id',$userId) -> field('id,amount') -> find();
        if($member){
            $member -> amount = $member -> amount + $amount;
            $member -> save();

            $flow = new MemberFlow();
            $data['type'] = 1;
            $data['text_content'] = '充值';
            $data['money'] = $amount;
            $data['uid'] = $userId;
            $flow -> save($data);
            return true;
        }
        return false;
    }



}